#!/bin/bash
# auther: leman Lai
#date: 2020.2.25

echo "make mysql"

groupadd mysql
useradd mysql -g mysql  -s /bin/nologin

yum install ncurses-devel -y

##get boost
wget http://nchc.dl.sourceforge.net/project/boost/boost/1.59.0/boost_1_59_0.tar.gz
tar zxvf  boost_1_59_0.tar.gz 
mv boost_1_59_0  /usr/local/boost
rm -rf boost_1_59_0.tar.gz

##下载安装mysql5.7.13
wget http://dev.mysql.com/get/Downloads/MySQL-5.7/mysql-5.7.13.tar.gz
tar -zxvf mysql-5.7.13.tar.gz
cd mysql-5.7.13
cmake -DCMAKE_INSTALL_PREFIX=/usr/local/mysql -DMYSQL_DATADIR=/usr/local/mysql/data \
     -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci  -DMYSQL_TCP_PORT=3306 \ 
    -DMYSQL_USER=mysql -DWITH_MYISAM_STORAGE_ENGINE=1 -DWITH_INNOBASE_STORAGE_ENGINE=1 \
    -DWITH_ARCHIVE_STORAGE_ENGINE=1 -DWITH_BLACKHOLE_STORAGE_ENGINE=1 -DWITH_MEMORY_STORAGE_ENGINE=1 \ 
    -DDOWNLOAD_BOOST=1 -DWITH_BOOST=/usr/local/boost
	
	
make && make install 

#初始化数据库
/usr/local/mysql/bin/mysqld --initialize 

cp /usr/local/support-files/my-default.cnf  /etc/my.cnf

cp support-files/mysql.server /etc/init.d/mysqld

chkconfig --add mysqld     # 添加到系统服务
chkconfig mysqld on 

service mysqld start
